--This is shared.lua

GM.Name = "Dodgeball Beta"
GM.Version			=	131
GM.Author			=	"Chopknee"
GM.Email			=	"Dugan1741@yahoo.com"
GM.Website			=	""
GM.TeamBased		=	true

CreateConVar("db_fps_death", 1, FCVAR_NOTIFY )


function add_maps_to_list( )
	GAMEMODE.mapVotes = { 0 }
	print( "Looking for maps in the maps directory..." )
	GAMEMODE.maps = file.Find( "maps/db_*.bsp", true )
	print( "Maps located, looking for user specified maps..." )
	if ( GetConVar( "db_forced_maps" ):GetString( ) != nil ) then
		table.Add( GAMEMODE.maps, string.Explode( "," , GetConVar( "db_forced_maps" ):GetString( ) ) )
	end
	for _, v in pairs(GAMEMODE.maps) do
		table.insert(GAMEMODE.mapVotes, 0, 0)
	end
	for _, v in pairs ( GAMEMODE.maps ) do
		Msg( v .. "\n" )
	end
end

--Delay adding the maps for 1 second to allow the configuration time to execute.
if (SERVER) then
	timer.Simple( 1, add_maps_to_list )
end

function GM:CreateTeams( )
	if ( !GAMEMODE.TeamBased ) then return end
	
	TEAM_COMBINE = 1
	team.SetUp( TEAM_COMBINE, "Combine", Color( 0, 0, 255 ) )
	team.SetSpawnPoint( TEAM_COMBINE, "info_player_terrorist" )
	
	TEAM_LAMBDA = 2
	team.SetUp( TEAM_LAMBDA, "Lambda", Color( 0, 255, 0 ) )
	team.SetSpawnPoint( TEAM_LAMBDA, "info_player_counterterrorist" )
	
	TEAM_DEADCOMB = 3
	team.SetUp( TEAM_DEADCOMB, "Out Combine", Color( 120, 120, 255) )
	team.SetSpawnPoint( TEAM_DEADCOMB, "info_player_start")

	TEAM_DEADLAMB = 4
	team.SetUp( TEAM_DEADLAMB, "Out Lambda", Color( 120, 255, 120) )
	team.SetSpawnPoint( TEAM_DEADLAMB, "info_player_start")
	
	team.SetSpawnPoint( TEAM_SPECTATOR, "info_player_start" ) 

end

function GM:ShutDown( )
	if (CLIENT) then
		RunConsoleCommand( "db_save_info", "" )
		return
	end
	Save_All_Player_Data( )
end
